import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../../utils/bt_constants.dart';
import '../repository/bt_profile_repository.dart';

class BtAccountSettingModel extends ChangeNotifier {
  late final BtProfileRepository repository;

  bool _switchValue = false;

  bool get switchValue => _switchValue;

  late SharedPreferences prefs;

  BtAccountSettingModel() {
    repository = BtProfileRepository();
    SharedPreferences.getInstance().then((value) {
      prefs = value;
      _switchValue = prefs.getBool(autoTranslateFlag) ?? false;
      notifyListeners();
    });
  }

  void setSwitchValue(bool switchValue) {
    _switchValue = switchValue;
    prefs.setBool(autoTranslateFlag, _switchValue);
    notifyListeners();
  }

  void logout(Function(bool success, String msg) onResult) {
    repository.logout(onResult);
  }

  void deleteAccount(Function(bool success, String msg) onResult) {
    repository.deleteAccount(onResult);
  }
}
